<template>
	<view>
		<view class="u-p-20" >
			<view class="u-font-28 u-text-right u-weight" @click="$u.route('/subcontract/myscore/change/massage/massage')">兑换记录</view>
			<view class="u-m-t-20 u-flex u-row-between" style="border-bottom: 1rpx solid #E1E1E1;">
				<view>兑换抵扣金:</view>
				<u-input v-model='money' type='number' placeholder='请输入兑换数量' :border='false' input-align='right'></u-input>
			</view>
			<view class="u-m-t-20 u-flex u-row-between u-font-28" style="color: #898989;">
				<view class="u-flex">
					<view class="">可用积分:</view>
					<view class=" u-flex ">
						<view class="u-h-40">
							<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/money.png" mode="aspectFill" width="22rpx"height='22rpx'></u-image>
						</view>
						
						<view class="" style="color: #FF5502FF;">{{info.score}}</view>
					</view>
				</view>
				<view class="u-flex">
					<view class="">所需积分:</view>
					<view class=" u-flex -m-l-10">
						<view class="u-h-40">
							<u-image src="https://www.sqkjkj.vip/wxImg/common/shop/money.png" mode="aspectFill" width="22rpx"height='22rpx'></u-image>
						</view>
						<view class="" style="color: #FF5502FF;">{{count}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="u-p-20 u-m-t-50">
			<view class="u-text-center u-font-20" style="padding-bottom: 10rpx; color:#898989 ;">积分兑换比例<text style="color:#FF5502FF;">{{info.exchange_rate}}:1</text></view>
			<view @click="score_exchange_deduct"
				class="u-w-650 u-auto u-h-100 u-l-h-100 u-text-center  u-b-r-13 cl_FFF"
				style="background: linear-gradient(-64deg, #FF382C, #FF633F);">提交</view>
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info:'',
				mobile: "",
				money: ''
			}
		},
		computed:{
			count(){
				return Number(this.money)*Number(this.info.exchange_rate)
			}
		},
		onShow() {
			this.score_deduct_init()
		},
		methods: {
			score_deduct_init(){
				this.$api.score_deduct_init({},res=>{
					if (res.data.code == 1) {
						this.info=res.data.data
					}
				})
			},
			score_exchange_deduct(){
				this.$api.score_exchange_deduct({get_deduct:this.money},res=>{
					if (res.data.code == 1) {
						this.$refs.uToast.show({
							title: res.data.msg,
							type: 'success',
							callback: cal => {
								uni.navigateBack()
							}
						})
					}
				})
			}
		}
	}
</script>

<style scoped>
	.one {
		width: 307rpx;
		height: 178rpx;
		background: url('https://www.sqkjkj.vip/wxImg/mybag/img3.png') no-repeat;
		background-size: 100% 100%;
	}

	.one1 {
		width: 307rpx;
		height: 178rpx;
		background: url('https://www.sqkjkj.vip/wxImg/mybag/img2.png') no-repeat;
		background-size: 100% 100%;
	}
</style>
